home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Caml Light 0.61 / Source / src / lib / ref.mli < prev    next >
Encoding:
Text File  |  1993-09-24  |  682 b   |  17 lines  |  [TEXT/MPS ]

  1. (* Operations on references *)
  2.  
  3. type 'a ref = ref of mutable 'a;;
  4.  
  5. value prefix ! : 'a ref -> 'a = 1 "field0"
  6.         (* [!r] returns the current contents of reference [r].
  7.            Could be defined as [fun (ref x) -> x]. *)
  8.   and prefix := : 'a ref -> 'a -> unit = 2 "setfield0"
  9.         (* [r := a] stores the value of [a] in reference [r]. *)
  10.   and incr : int ref -> unit = 1 "incr"
  11.         (* Increment the integer contained in the given reference.
  12.            Could be defined as [fun r -> r := succ !r]. *)
  13.   and decr : int ref -> unit = 1 "decr"
  14.         (* Decrement the integer contained in the given reference.
  15.            Could be defined as [fun r -> r := pred !r]. *)
  16. ;;
  17.